package com.etoak.vo;

import com.etoak.enums.ResultEnums;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2024/7/4 11:14
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultVo<T> {

    private Integer code;
    private String message;
    private T data;

    public static <T> ResultVo<T> success(){
        return success(null);
    }

    public static <T> ResultVo<T> success(T data){
        return  new ResultVo<T>(ResultEnums.SUCCESS.getCode(), ResultEnums.SUCCESS.getMsg(), data);
    }

    public static <T> ResultVo<T> failed(){
        return failed(ResultEnums.SYSTEM_ERROR);
    }

    public static <T> ResultVo<T> failed(ResultEnums resultEnums) {
        return failed(resultEnums.getCode(),resultEnums.getMsg());
    }

    public static <T> ResultVo<T> failed( String msg) {
        return failed(ResultEnums.SYSTEM_ERROR.getCode(), msg);
    }

    public static <T> ResultVo<T> failed(int code, String msg) {
        return  new ResultVo<>(code,msg,null);
    }


}
